import { Controller, Get, Param } from '@nestjs/common';
import { ConfigService } from './config.service';
import { Config } from '../../entities/config.entity';
import { ApiTags, ApiOperation, ApiResponse, ApiParam } from '@nestjs/swagger';

@ApiTags('配置管理')
@Controller('api/config/user')
export class ConfigUserController {
  constructor(private readonly configService: ConfigService) {}

  // 获取单个配置（需要登录）
  @Get(':key')
  @ApiOperation({
    summary: '获取单个配置',
    description: '根据配置键获取配置信息',
  })
  @ApiParam({
    name: 'key',
    description: '配置键名',
    example: 'site_title',
  })
  @ApiResponse({
    status: 200,
    description: '获取成功',
    type: Config,
  })
  @ApiResponse({
    status: 401,
    description: '用户未登录',
  })
  @ApiResponse({
    status: 404,
    description: '配置不存在',
  })
  findOne(@Param('key') key: string) {
    return this.configService.findOne(key);
  }
}